package com.example.guli.service.base.exception;

import com.example.guli.common.base.result.ResultCodeEnum;
import lombok.Data;

/**
 * @创建人 shunxuan
 * 创建时间 2020/7/18
 * @描述 自定义异常类
 * RuntimeException 运行时异常
 **/
@Data
public class GuliException extends RuntimeException{
    //状态码
    private Integer code;
    /**
     * 接受状态码和消息
     * @param code
     * @param message
     */
    public GuliException(String message, Integer code) {
        super(message);
        this.code = code;
    }
    /**
     * 接收枚举类型
     * @param resultCodeEnum
     */
    public GuliException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    @Override
    public String toString() {
        return "GuliException{" +
                "code=" + code +
                ",message=" + this.getMessage() +
                '}';
    }
}
